using System;
using System.Collections.Generic;
using System.Text;

namespace cmdPhone
{
    /// <summary>
    /// Class created to abstract the output of the application
    /// in order to increase reusability of the code
    /// </summary>
    static class Interaction
    {
        /// <summary>
        /// Method to deal with Exceptions
        /// Mostly to be used if more logging details are required
        /// in the future.
        /// </summary>
        /// <param name="ex">Exception</param>
        public static void dealWithException(Exception ex)
        {
            if (ex.Message.Contains(Resources.text_identify_exception_max_number_of_daily_requests))
            {
                Interaction.output(Resources.exception_explanation_max_number_of_daily_requests);
            }
            else if(ex.Message.Contains(Resources.text_identify_exception_cert_expired))
            {
                Interaction.output(Resources.exception_explanation_cert_expired);
            }
            else 
            {
                Interaction.output(ex.Message);
            }
            
        }


        /// <summary>
        /// Method to provide feedback to the user
        /// </summary>
        /// <param name="sentence">Actual text for the user</param>
        public static void output(string sentence)
        {
            Console.WriteLine("");
            Console.WriteLine(sentence);
        }


        /// <summary>
        /// Method to provide feedback to the user without the empty line beforehand
        /// </summary>
        /// <param name="sentence">Actual text for the user</param>
        public static void outputNoSpace(string sentence)
        {
            Console.WriteLine(sentence);   
        }


        /// <summary>
        /// Method to obtain input from user
        /// </summary>
        /// <returns>what the user has typed</returns>
        public static string input() 
        {
            Interaction.outputNoSpace("");
            return Console.ReadLine();
        }


        /// <summary>
        /// Method to obtain input from user without the empty line beforehand
        /// </summary>
        /// <returns></returns>
        public static string inputNoSpace() 
        {
            return Console.ReadLine();
        }

    }
}
